<template>
  <view class="search-component">
    <view class="search-layout" v-if="inputType == 1">
      <view class="qr-code">
        <text class="ai-text">Ai</text>
      </view>
      <view class="search-box">
        <view class="input-left">
          <view class="location-text">北京</view>
          <text class="iconfont icon-weibiaoti--10"></text>
        </view>
        <view class="search-text-list" @click="inputType = 2">
          <swiper
            class="swiper"
            circular
            :vertical="true"
            :autoplay="true"
            :interval="5000"
            :duration="300"
          >
            <swiper-item>
              <view class="swiper-item uni-bg-red"
                >大麦·周杰伦 <text class="red-text">HOT</text></view
              >
            </swiper-item>
            <swiper-item>
              <view class="swiper-item uni-bg-green">大麦·薛之谦</view>
            </swiper-item>
            <swiper-item>
              <view class="swiper-item uni-bg-blue">大麦·王力宏</view>
            </swiper-item>
          </swiper>
        </view>
        <view class="input-right">
          <text class="iconfont icon-weibiaoti--17"></text>
          <view class="search-btn">搜索</view>
        </view>
      </view>
    </view>
    <!-- 输入搜索内容 -->
    <view class="search-layout-input" v-if="inputType == 2">
      <view class="search-input-box">
        <input
          type="text"
          class="search-input"
          v-model="inputValue"
          placeholder="薛之谦"
          placeholder-class="placeholder-style"
          :focus="true"
        />
        <text
          v-if="inputValue != ''"
          class="iconfont end-icon icon-weibiaoti--13"
          @click="clearInputValue"
        ></text>
      </view>

      <text class="cancel-btn" @click="inputType = 1">取消</text>
    </view>
  </view>
</template>

<script>
import { defineComponent, reactive, toRefs } from "vue";
export default defineComponent({
  name: "search002",
  props: {},
  components: {},
  setup() {
    const data = reactive({
      inputType: 1,
      inputValue: "",
    });
    const clearInputValue = () => {
      data.inputValue = "";
    };
    return {
      clearInputValue,
      ...toRefs(data),
    };
  },
});
</script>

<style scoped lang="less">
.search-component {
  .search-layout {
    display: flex;
    justify-content: space-between;
    height: 90rpx;
    padding: 10rpx 20rpx;
    box-sizing: border-box;
    background: linear-gradient(to right bottom, #ffbab8, #ffe7a4, #fff);
    .qr-code {
      line-height: 70rpx;
      padding-right: 20rpx;
      .ai-text {
        font-size: 50rpx;
        color: #f14400;
        font-weight: 700;
        //文字倾斜
        font-style: italic;
      }
    }
    .search-box {
      flex: 1;
      position: relative;
      .search-text-list {
        height: 100%;
        line-height: 62rpx;
        box-sizing: border-box;
        color: #000;
        border-radius: 10rpx;
        background: #fff;
        border: 4rpx solid #000;
        padding-left: 120rpx;
        overflow: hidden;
        .swiper {
          height: 100%;
          .t-icon-guanjun {
            width: 40rpx;
            height: 40rpx;
          }
          .red-text {
            color: #fff;
            height: 22rpx;
            line-height: 22rpx;
            background: red;
            padding: 0 8rpx;
            border-radius: 14rpx 14rpx 14rpx 0;
            font-size: 22rpx;
            margin-left: 10rpx;
            font-weight: 700;
          }
          .swiper-item {
            display: flex;
            align-items: center;
            font-size: 24rpx;
            font-weight: 300;
          }
        }
      }
      .input-left {
        display: flex;
        align-items: center;
        position: absolute;
        top: 10rpx;
        left: 20rpx;
        .icon-weibiaoti--10 {
          display: block;
          // 旋转
          transform: rotate(-90deg);
          margin-left: 6rpx;
          font-size: 20rpx;
          font-weight: 700;
        }
        .location-text {
          font-weight: 700;
          font-size: 26rpx;
          line-height: 50rpx;
        }
      }
      .input-right {
        display: flex;
        align-items: center;
        position: absolute;
        top: 10rpx;
        right: 10rpx;
        .icon-weibiaoti--17 {
          font-size: 36rpx;
          margin-right: 20rpx;
          color: #999;
        }
        .search-btn {
          height: 50rpx;
          line-height: 50rpx;
          border-radius: 10rpx;
          padding: 0 25rpx;
          font-size: 24rpx;
          color: #fff;
          // 渐变
          background: linear-gradient(
            to right bottom,
            #ff3300,
            #ffa600,
            #ff3300
          );
        }
      }
    }
  }
  .search-layout-input {
    display: flex;
    justify-content: space-between;
    height: 90rpx;
    padding: 10rpx 20rpx;
    padding-right: 0rpx;
    box-sizing: border-box;
    background: linear-gradient(to right bottom, #ffbab8, #ffe7a4, #fff);
    .search-input-box {
      position: relative;
      flex: 1;

      .search-input {
        width: 100%;
        height: 100%;
        padding-left: 20rpx;
        box-sizing: border-box;
        color: #000;
        border-radius: 10rpx;
        background: #fff;
        border: 4rpx solid #000;
        overflow: hidden;
        font-size: 24rpx;
        //   placeholder样式修改
        .placeholder-style {
          color: #777;
        }
      }
      .end-icon {
        font-size: 30rpx;
        position: absolute;
        color: #999;
        right: 20rpx;
        top: 50%;
        transform: translateY(-50%);
      }
    }
    .cancel-btn {
      line-height: 70rpx;
      padding: 0 20rpx;
      font-size: 28rpx;
      font-weight: 500;
    }
  }
}
</style>
